# CMake module file to find zookeeper
# Following variables will be defined in this module
# ZOOKEEPER_FOUND             - whether ZOOKEEPER is found
# ZOOKEEPER_INCLUDE_DIRS      - include directories for ZOOKEEPER
# ZOOKEEPER_LIBRARIES         - link this to use ZOOKEEPER

UNSET(ZOOKEEPER_FOUND)

# set the target libraries
# link the multi-thread lib of zookeeper
# use libzookeeper_st.a instead if pthead is not available
SET(ZOOKEEPER_TARGET_LIBRARIES libzookeeper_mt.so)
# set the include directories
SET(ZOOKEEPER_INCLUDE_DIRS /usr/local/include/zookeeper)

# find libraries
FOREACH(LIB ${ZOOKEEPER_TARGET_LIBRARIES})
    FIND_LIBRARY(${LIB}_PATH NAMES ${LIB} HINTS /usr/local/lib NO_DEFAULT_PATH)
    SET(ZOOKEEPER_LIBRARIES ${ZOOKEEPER_LIBRARIES};${${LIB}_PATH})
ENDFOREACH()

IF(ZOOKEEPER_LIBRARIES AND ZOOKEEPER_INCLUDE_DIRS)
    SET(ZOOKEEPER_FOUND TRUE)
ENDIF(ZOOKEEPER_LIBRARIES AND ZOOKEEPER_INCLUDE_DIRS)

IF(ZOOKEEPER_FOUND)
    IF(NOT zookeeper_FIND_QUIETLY)
        MESSAGE(STATUS "ZOOKEEPER LIBRARIES ARE ${ZOOKEEPER_LIBRARIES}")
        MESSAGE(STATUS "ZOOKEEPER INCLUDES ARE FOUND in ${ZOOKEEPER_INCLUDE_DIRS}")
    ENDIF(NOT zookeeper_FIND_QUIETLY)
ELSE(ZOOKEEPER_FOUND)
    IF(zookeeper_FIND_REQUIRED)
        MESSAGE(FATAL_ERROR "ZOOKEEPER IS NOT FOUND" )
    ENDIF(zookeeper_FIND_REQUIRED)
ENDIF(ZOOKEEPER_FOUND)